package xsis.music.controller;
import java.util.Collection;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import xsis.music.model.BarangModel;
import xsis.music.model.KategoriModel;
import xsis.music.service.AdminService;

@Controller
public class AdminController {
	
	@Autowired
	AdminService adminService;
	
	@RequestMapping("/index.html")
	public String homeAdmin(HttpServletRequest req, HttpServletResponse resp) {
		try {
			Collection<BarangModel> list = adminService.listAllBarang();
			Collection<KategoriModel> listKategori = adminService.listAllKategori();
			req.setAttribute("kategori", listKategori);
			req.setAttribute("barang", list);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return "homeAdmin";
	}

}